<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>添加管理员</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="${global_templets_skin}/systemstyle/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="${global_templets_skin}/systemstyle/style/admin.css" media="all">
  <style>
    .layui-upload-img{width: 92px; height: 92px; margin: 0 10px 10px 0;}
    #avatar-upload-normal{ float: left;}
    #avatar-upload-avatarText{ float: left;margin-left: 10px}
    .avatar-reload{margin-left: 10px}
  </style>
</head>
<body>

  <div class="layui-fluid">
    <div class="layui-row layui-col-space15">
      <div class="layui-col-md12">
        <div class="layui-card">
          <div class="layui-card-header">新增管理员信息</div>
          <div class="layui-card-body" pad15>
            <div class="layui-form" lay-filter="">
              <div class="layui-form-item">
                <label class="layui-form-label">我的角色</label>
                <div class="layui-input-block">
                    <div class="layui-col-md12">
                      <#list roles as role>
                      <input type="checkbox" name="roleId[]"  value="${role.id!}" title="${role.roleName}">
                      </#list>
                    </div>
                </div>
                <div class="layui-form-mid layui-word-aux">用户最少需要一个角色，可多个角色</div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">用户名</label>
                <div class="layui-input-inline">
                  <input type="text" name="userName" value="" lay-verify="username" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">网站后台登陆用户名。一般用于后台登入名</div>
              </div>
            <div class="layui-form-item">
              <label class="layui-form-label">登陆密码</label>
              <div class="layui-input-inline">
                <input type="password" name="password" value="" lay-verify="pass" class="layui-input">
              </div>
              <div class="layui-form-mid layui-word-aux">网站后台登陆用户名。一般用于后台登入名</div>
            </div>
              <div class="layui-form-item">
                <label class="layui-form-label">昵称</label>
                <div class="layui-input-inline">
                  <input type="text" name="nickname" value="" lay-verify="nickname" autocomplete="off" placeholder="请输入昵称" class="layui-input">
                </div>
              </div>
            <div class="layui-form-item layui-form-text">
              <label class="layui-form-label">个性签名</label>
              <div class="layui-input-block">
                <input type="text" name="sign" value="" autocomplete="off" placeholder="个性签名，不能超过80个字符" class="layui-input">
              </div>
            </div>
              <div class="layui-form-item">
                <label class="layui-form-label">性别</label>
                <div class="layui-input-block">
                  <input type="radio" name="sex" value="1" title="男" checked>
                  <input type="radio" name="sex" value="0" title="女">
                </div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">头像</label>
                <div class="layui-input-block">
                  <div class="layui-upload">
                    <div class="layui-upload-list">
                      <img class="layui-upload-img" id="avatar-upload-normal-img">
                    </div>
                    <button type="button" class="layui-btn" id="avatar-upload-normal">上传图片</button>
                    <p id="avatar-upload-avatarText"></p>
                  </div>
                </div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">手机</label>
                <div class="layui-input-inline">
                  <input type="text" name="cellphone" value="" lay-verify="phone" autocomplete="off" class="layui-input">
                </div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">邮箱</label>
                <div class="layui-input-inline">
                  <input type="text" name="email" value="" lay-verify="email" autocomplete="off" class="layui-input">
                </div>
              </div>
              <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">自我描述</label>
                <div class="layui-input-block">
                  <textarea name="account" placeholder="自我描述" class="layui-textarea"></textarea>
                </div>
              </div>
            <div class="layui-form-item" lay-filter="component-form-element">
              <label class="layui-form-label">用户状态</label>
              <div class="layui-input-inline">
                <input type="checkbox" name="status" value="1" lay-skin="switch" lay-text="开启|关闭" checked>
              </div>
            </div>
              <div class="layui-form-item">
                <div class="layui-input-block">
                  <button class="layui-btn" lay-submit lay-filter="setmyinfo">确认修改</button>
                  <button type="reset" class="layui-btn layui-btn-primary">重新填写</button>
                </div>
              </div>
            </div>
            
          </div>
        </div>
      </div>
    </div>
  </div>

  <script src="${global_templets_skin}/systemstyle/layui/layui.js"></script>
  <script>
      layui.config({
          base: '${global_templets_skin}/systemstyle/' //静态资源所在路径
      }).extend({
          index: 'lib/index' //主入口模块
      }).use(['index', 'set'], function () {
          var form   = layui.form;
          var $      = layui.jquery;
          var layer  = layui.layer;

          form.on('submit(setmyinfo)', function(data) {
              $.ajax({
                  url:'/admin/user/add_admin.do',
                  type:'post',
                  dataType: 'json',
                  data: data.field,
                  success:function(e){
                      if (e.code == "0") {
                          layer.msg('成功');
                          window.location.reload();
                      }else {
                          layer.msg('失败');
                      }
                  }
              })
              //防止页面跳转
              return false;
          });
      });
  </script>

</body>
</html>